<%--
 *  File:    BookSetSummary.jsp
 *  @Author: Jianni 
 *  Date:    2002/01/28
 *
 *  Copyright (C) 2000 - 2002 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<% //--------------------------------------  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.BookSetSummary");  
%>

<% //--------------------------------------  variant and initialization --%>
<%
	String strModuleName = "SPM";
  	String strTableName = "ovbookset";
	String privilegeCode = "40104";
%>



<%
  	HashMap userInfo = (HashMap)session.getAttribute("userinfo");  
  	int grade = -1;
  	if(userInfo.get("grade") != null)
  	{
  	  grade = ((Integer)userInfo.get("grade")).intValue();
  	}
  	String strClassType = "";  
%>

<% //--------------------------------------  include files list --%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>



<html>
<head>
<title>BookSetSummary</title>
<PageFlow:CheckPageFlow pageName="booksetsummary"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../../js/FuncLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<script language="JavaScript">
parent.down.location.href = "Blank.jsp?<%= OvalTools.randomURL() %>";
function clickBookset(id, status)
{
  	parent.down.location.href = "Blank.jsp?<%= OvalTools.randomURL() %>";
  	document.booksetsummaryform.booksetid.value = id;
  	document.booksetsummaryform.status.value = status;
}
function page_delete()
{
	var status = document.booksetsummaryform.status.value;
	if(status>=40)
	{
    alert("<%= message.getMessageDesc("ALREADY_ACTIVED",label.getLabelName("L_BooksetApplied",false)) %>"); 
		return;
	}
	if(status>27)
	{
    alert("<%= message.getMessageDesc("CAN_NOT_DEL_IT") %>"); 
		return;
	}
	var id = document.booksetsummaryform.booksetid.value;
  	if(id == null || id.length == 0 || id == "" || id == "-1")
    	return;
  	var flag = confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>");
  	if(!flag)
    	return;
  	document.booksetsummaryform.actionname.value = "delete";
  	document.booksetsummaryform.target = "_parent";
  	isRunning = true;  
  	document.booksetsummaryform.submit();
}
function page_edit()
{
	var status = document.booksetsummaryform.status.value;
	if(status>=40 )
	{
    	  alert("<%= message.getMessageDesc("ALREADY_ACTIVED",label.getLabelName("L_BooksetApplied",false)) %>"); 
	  return;
	}	
	if(status==23)
	{
	  alert("<%= message.getMessageDesc("CAN_NOT_EDIT_IT") %>"); 
	  return;
	}
  	var id = document.booksetsummaryform.booksetid.value;
  	if(id == null || id.length == 0 || id == "" || id == "-1")
  	{
    	return;
  	}
  	var link = "BookSetEdit.jsp?<%= OvalTools.randomURL() %>&orgid=<%=JspHelper.filterNull( userInfo.get("orgid"))%>&booksetid=" + id + "&languagecode=" + "<%= strLanguageCode %>";  
  	parent.down.location.href = link;
}
function page_new()
{
	var link = "BookSetEdit.jsp?<%= OvalTools.randomURL() %>&orgid=<%=JspHelper.filterNull( userInfo.get("orgid"))%>&languagecode=" + "<%= strLanguageCode %>";  
  	parent.down.location.href = link;
}
function page_active()
{
	var status = document.booksetsummaryform.status.value;
	if(status>=40)
	{
    	  alert("<%= message.getMessageDesc("ALREADY_ACTIVED",label.getLabelName("L_BooksetApplied",false)) %>"); 
	  return;
	}
	if(status==23)
	{
	  alert("<%= message.getMessageDesc("CAN_NOT_ACTIVE_STOPED_BOOKSET") %>"); 
	  return;
	}	
  	var id = document.booksetsummaryform.booksetid.value;
  	if(id == null || id.length == 0 || id == "" || id == "-1")
    	return;
  	var flag = confirm("<%= message.getMessageDesc("ARE_YOU_SURE_ACTIVE") %>");
  	if(!flag)
    	return;
  	document.booksetsummaryform.actionname.value = "active";
  	document.booksetsummaryform.target = "_parent";  
  	isRunning = true;
  	document.booksetsummaryform.submit();
}
function page_summary(actionvalue,orderbyname)
{
	var editform = summaryPrepare(booksetsummaryform,actionvalue,orderbyname);
  	editform.action = "BookSetSummary.jsp?<%= OvalTools.randomURL() %>";
  	editform.target = "_self";
  	isRunning = true;
  	editform.submit();  
}
function page_booksetorg()
{
  parent.down.location.href = "BookSetOrg.jsp?<%= OvalTools.randomURL() %>&booksetid="+ document.booksetsummaryform.booksetid.value +"&languagecode=<%= strLanguageCode %>";
}
function page_stop()
{
  var status = document.booksetsummaryform.status.value;
  if(status!=43)
    return;
  if(!confirm("<%= message.getMessageDesc("ARE_YOU_SURE") %>"))
    return;
  document.booksetsummaryform.actionname.value = "stop";
  document.booksetsummaryform.target = "_parent";
  isRunning = true;
  document.booksetsummaryform.submit();
}
</script>

<% //--------------------------------------  output variant from pageflow --%>
<%
	Vector booksetSummary = (Vector)pageContext.getAttribute("booksetsummary");
  	if(booksetSummary == null)
  	{
    	booksetSummary = new Vector();
  	}
%>
</head>
<body>

	<% //--------------------------------------  hidden form variant --%>
	<form name="booksetsummaryform" method="post" action="../../Dispatcher">
    <input type="hidden" name="pagename" value="booksetsummary">
    <input type="hidden" name="actionname">
    <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">
    <input type="hidden" name="nullflag" value=" ">
    <custom:hidden property="booksettype" />

	
    <% //--------------------------------------  page location --%>
	<%@ include file="/inc/PageLocation.inc" %>
	
	<%--------------------------------------  page content   --%>
	<table width="100%" cellspacing="0" border="0" cellpadding="0">
  	<tr>
    <td> 
      <table width="100%" border="0" cellspacing="0">
        <tr> 
          <td class="summary_top" colspan="2" ></td>
        </tr>
  		<%@ include file="/inc/SummarySearch.inc" %>	
      </table>
    </td>
  	<tr> 
    	<td> 
      		<table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
      		
      		<% //--------------------------------------  summary header --%>
          	<tr class="deepblue-left"> 
            	<td width="22" class="title_center">&nbsp;</td>
            	<td class="title_center" width="60"><a href="javascript:page_summary('orderby','booksetcode')"><%= label.getLabelName("L_BooksetCode") %></a></td>
            	<td class="title_center"		   ><a href="javascript:page_summary('orderby','booksetname')"><%= label.getLabelName("L_BooksetName") %></a></td>
            	<td width="80" class="title_center"><a href="javascript:page_summary('orderby','begindate')"><%= label.getLabelName("L_BeginningDate") %></a></td>
            	<td width="60" class="title_center"><a href="javascript:page_summary('orderby','currencyname')"><%= label.getLabelName("L_HomeCurrency") %></a></td>
            	<td width="60" class="title_center"><a href="javascript:page_summary('orderby','accperiodnum')"><%= label.getLabelName("L_NoOfAP") %></a></td>
            	<td class="title_center" width="70"><a href="javascript:page_summary('orderby','beginmonth')"><%= label.getLabelName("L_BeginningMonth") %></a></td>
            	<td class="title_center" width="70"><a href="javascript:page_summary('orderby','endmonth')"><%= label.getLabelName("L_EndingMonth") %></a></td>
            	<td class="title_center" width="35"><a href="javascript:page_summary('orderby','statusname')"><%= label.getLabelName("L_Status") %></a></td>
          	</tr>
          
          	<% //--------------------------------------  default value definition --%>
          	<%
            	Integer nDefaultBooksetId = new Integer(-1); 
            	Integer nDefaultStatus = new Integer(-1); 
          	%>
  			
  			<% //--------------------------------------  loop results --%>
  			<logic:iterate id="ps" collection="<%= booksetSummary %>" indexId="orderId">                      
          	<%
            	HashMap psMap = (HashMap)ps;
            	String strIsChecked = new String("");
          
            	if((orderId.intValue())%2 == 1)
            	{
              		strClassType = "td-listrom";
            	}else{                    
              		strClassType = "none";
            	}
            	if(orderId.intValue()==0)
            	{
              		strIsChecked = "Checked";                       
              		nDefaultBooksetId = (Integer)(psMap.get("booksetid"));
              		nDefaultStatus = (Integer)(psMap.get("status"));
            	}                
           	%>
          	<tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'"  onClick="javascript:radiotrue('bookset<%=JspHelper.filterNull( orderId )%>');clickBookset('<%=JspHelper.filterNull( psMap.get("booksetid") )%>', '<%=JspHelper.filterNull( psMap.get("status") )%>');" class="<%=JspHelper.filterNull( strClassType )%>"> 
            	<td height="22">
              		<input id="bookset<%=JspHelper.filterNull( orderId )%>" type="radio" name="booksetids" value=<%=JspHelper.filterNull( psMap.get("booksetid") )%> class="normalradio" <%=JspHelper.filterNull( strIsChecked)%> onClick="javascript:clickBookset('<%=JspHelper.filterNull( psMap.get("booksetid") )%>', '<%=JspHelper.filterNull( psMap.get("status") )%>')">
            	</td>
            	<td width="60"><a href="BookSetInfo.jsp?<%= OvalTools.randomURL() %>&booksetid=<%=JspHelper.filterNull( psMap.get("booksetid"))%>" target="down"><%=JspHelper.filterNull( psMap.get("booksetcode") )%></a>&nbsp;</td>
            	<td>&nbsp;<%=JspHelper.filterNull( psMap.get("booksetname") )%></td>
            	<td width="80">&nbsp;<%= OvalTools.dateToString(psMap.get("begindate"),(String)session.getAttribute("dateformat")) %></td>
            	<td width="60">&nbsp;<%=JspHelper.filterNull( psMap.get("currencyname") )%></td>
            	<td width="60">&nbsp;<%=JspHelper.filterNull( psMap.get("accperiodnum") )%></td>            
            	<td width="70">&nbsp;<%=JspHelper.filterNull( psMap.get("beginmonth") )%>/<%=JspHelper.filterNull( psMap.get("beginday") )%></td>
            	<td width="70">&nbsp;<%=JspHelper.filterNull( psMap.get("endmonth") )%>/<%=JspHelper.filterNull( psMap.get("endday") )%></td>
            	<td width="35">&nbsp;<%=JspHelper.filterNull( psMap.get("statusname") )%></td>
          	</tr>
          	</logic:iterate>                   
          	
          	<% //--------------------------------------  default value --%>       
          	<input type="hidden" name="booksetid" value="<%=JspHelper.filterNull( nDefaultBooksetId )%>">  
          	<input type="hidden" name="status" value="<%=JspHelper.filterNull( nDefaultStatus )%>">  
           
          	<% //--------------------------------------  flipping page --%>
    		<%@ include file="/inc/SummaryAction.inc" %>
    		
      		</table>
            </td>
          </tr>    
			
			<% //--------------------------------------  page operation button --%>
      		<table width="100%" cellspacing="0" cellpadding="0">
        	<tr> 
        		<td class="summary_top"></td>
        	</tr>
        	<tr> 
          		<td class="td_center">
          		<%if(grade == 1){%>
          		  <a onclick="page_new()"><custom:button type="1" label="L_New" imgsrc="new.gif" border="0" style="width:60"/></a>
          		  <a onclick="page_edit()"><custom:button type="1" label="L_Edit" imgsrc="edit.gif" border="0" style="width:60"/></a>
          		  <a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a>
          		  <a onclick="page_active()"><custom:button type="1" label="L_Startup" imgsrc="Startup.gif" border="0" style="width:60"/></a>          		  
          		<%}%>
          		<%if(booksetSummary.size()!=0){%>
          		  <a onclick="page_stop()"><custom:button type="1" label="L_Shutoff" imgsrc="Shutoff.gif" border="0" style="width:60"/></a>
          		  <a onclick="page_booksetorg()"><custom:button type="1" label="L_SetOrg" imgsrc="SetOrg.gif" border="0" style="width:60"/></a>
          		<%}%>
          		</td>
        	</tr>
      		</table>     		
   		</td>
  	</tr>
</table>
</form>
</body>
</html>


